package com.first_javaee.service;

import com.first_javaee.entity.UserInfo;
import com.first_javaee.mapper.UserInfoMapper;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service    //自动装配的注解：可以自动实例化(自动new一个对象和Controller中的@Autowired搭配)
public class UserInfoSerivce {
    @Autowired
    private UserInfoMapper userInfoMapper;
//    public boolean checkLogin(String userCode,String userPwd){
//        boolean flag=false;
//        UserInfo userInfo=null;
//        userInfo=userInfoMapper.checkLogin(userCode,userPwd);
//        if (!userInfo.equals(null)){
//            flag=true;
//        }
//        return flag;
//    }
public boolean checkLogin(String userName, String userPwd){
    boolean flag = false;
    UserInfo userInfo = null;
    userInfo = userInfoMapper.checkLogin(userName, userPwd);
    if (!userInfo.equals(null))
        flag = true;
    return flag;
}

public void insertData(String userName, String userPwd){
    userInfoMapper.addUser(userName, userPwd);
}
}
